package com.coderman.business.service.imp;

import com.coderman.business.mapper.PayMentTypeMapper;
import com.coderman.business.service.IPayMentTypeService;
import com.coderman.business.service.base.AbstractServiceImpl;
import com.coderman.common.model.payMent.PayMentType;
import com.coderman.common.model.student.ObtainEmp;
import com.coderman.common.vo.system.PageVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import tk.mybatis.mapper.entity.Example;

import java.util.List;


@Service
public class PayMentTypeServiceImpl extends AbstractServiceImpl<PayMentTypeMapper, PayMentType, Integer> implements IPayMentTypeService {
    @Autowired
    private PayMentTypeMapper payMentTypeMapper;
    @Override
    public PageVO<PayMentType> findPayMentTypeList(Integer pageNum, Integer pageSize, PayMentType payMentType) {
        //已经拥有的
        PageHelper.startPage(pageNum,pageSize);
        Example o = new Example(PayMentType.class);
        String pmtypename = payMentType.getPmtypename();
        //Integer clsStatus = classVo.getClsstatus();
        Example.Criteria criteria = o.createCriteria();
        if(!StringUtils.isEmpty(pmtypename)){
            criteria.andLike("pmtypename","%"+pmtypename+"%");
        }

        List<PayMentType> classList= payMentTypeMapper.selectByExample(o);
        PageInfo<PayMentType> info=new PageInfo<>(classList);
        return new PageVO<>(info.getTotal(),classList);
    }

    @Override
    public List<PayMentType> findAll() {
        return payMentTypeMapper.selectAll();
    }

    @Override
    public void add(PayMentType payMentType) {
        payMentTypeMapper.insert(payMentType);
    }

    @Override
    public PayMentType edit(Integer id) {
        return payMentTypeMapper.selectByPrimaryKey(id);
    }

    @Override
    public void update(PayMentType payMentType) {
        payMentTypeMapper.updateByPrimaryKey(payMentType);
    }
}
